package njiandan.mvc.core;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

public class BilidInArgumentInfo {
	public final int argIndex;
	public final String argName;
	public final Class<?> argType;
	public final int typeCode;

	/**
	 * HttpServletRequest 
	 */
	public final static int TYPE_REQUEST = 0;

	/**
	 * HttpServletResponse 
	 */
	public final static int TYPE_RESPONSE = 1;

	/**
	 * HttpSession
	 */
	public final static int TYPE_SESSION = 2;

	/**
	 * Cookie[]  
	 */
	public final static int TYPE_COOKIES = 3;

	/**
	 * Cookie 
	 */
	public final static int TYPE_COOKIE = 4;

	BilidInArgumentInfo(int argIndex, String argName, Class<?> argType) {
		this.argIndex = argIndex;
		this.argName = argName;
		this.argType = argType;

		if (argType.equals(HttpServletRequest.class)) {
			typeCode = TYPE_REQUEST;
		} else if (argType.equals(HttpServletResponse.class)) {
			typeCode = TYPE_RESPONSE;
		} else if (argType.equals(HttpSession.class)) {
			typeCode = TYPE_SESSION;
		} else if (argType.equals(Cookie[].class)) {
			typeCode = TYPE_COOKIES;
		} else if (argType.equals(Cookie.class)) {
			typeCode = TYPE_COOKIE;
		} else {
			typeCode = -1;
		}
	}
}
